package com.faye.sdk.configuration;

import com.fasterxml.jackson.databind.ObjectMapper;
import io.modelcontextprotocol.server.transport.WebMvcSseServerTransportProvider;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.function.RouterFunction;
import org.springframework.web.servlet.function.ServerResponse;

@Configuration
@EnableWebMvc
public class McpServerConfiguration {
    @Bean
    public WebMvcSseServerTransportProvider webMvcSseServerTransport() {
        String MESSAGE_ENDPOINT = "/mcp/message";
        return new WebMvcSseServerTransportProvider(new ObjectMapper(), MESSAGE_ENDPOINT);
    }

    @Bean
    public RouterFunction<ServerResponse> routerFunction(WebMvcSseServerTransportProvider transport) {
        return transport.getRouterFunction();
    }
}
